<template>
  <div>
    <el-form ref="form" :model="form" label-width="120px" :inline="true">
      <el-row>
        <el-col :span="8">
          <el-form-item label="身高（cm）">
            <el-input v-model="form.height" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="体重（kg）">
            <el-input v-model="form.weight" />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="BMI:">
            <el-input v-model="form.bmi" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="眼睑下垂:">
            <el-select v-model="form.blepharoptosis" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="正常" value="1" />
              <el-option label="双眼" value="2" />
              <el-option label="左眼" value="3" />
              <el-option label="右眼" value="4" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="眼动障碍:">
            <el-select v-model="form.eyeMovementDisorder" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="有" value="1" />
              <el-option label="无" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="复视:">
            <el-select v-model="form.diplopia" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="有" value="1" />
              <el-option label="无" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="闭目:">
            <el-select v-model="form.sorenes" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="正常" value="1" />
              <el-option label="无力" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="鼓腮:">
            <el-select v-model="form.mumps" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="正常" value="1" />
              <el-option label="无力" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="构音障碍:">
            <el-select v-model="form.dysarthria" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="有" value="1" />
              <el-option label="无" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="屈颈:">
            <el-select v-model="form.drink" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="正常" value="1" />
              <el-option label="无力" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="伸颈:">
            <el-select v-model="form.neckFlexion" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="正常" value="1" />
              <el-option label="无力" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="脚尖走路:">
            <el-select v-model="form.toeWalking" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="正常" value="1" />
              <el-option label="无力" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="脚跟走路:">
            <el-select v-model="form.heelWalking" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="正常" value="1" />
              <el-option label="无力" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="蹲起:">
            <el-select v-model="form.squat" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="正常" value="1" />
              <el-option label="无力" value="2" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="左上肢近端肌力:">
            <el-select v-model="form.muscularStrength1" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="I" value="1" />
              <el-option label="II" value="2" />
              <el-option label="III" value="3" />
              <el-option label="IV" value="4" />
              <el-option label="V" value="5" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="左上肢远端肌力:">
            <el-select v-model="form.muscularStrength2" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="I" value="1" />
              <el-option label="II" value="2" />
              <el-option label="III" value="3" />
              <el-option label="IV" value="4" />
              <el-option label="V" value="5" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="右上肢近端肌力:">
            <el-select v-model="form.muscularStrength3" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="I" value="1" />
              <el-option label="II" value="2" />
              <el-option label="III" value="3" />
              <el-option label="IV" value="4" />
              <el-option label="V" value="5" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="右上肢远端肌力:">
            <el-select v-model="form.muscularStrength4" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="I" value="1" />
              <el-option label="II" value="2" />
              <el-option label="III" value="3" />
              <el-option label="IV" value="4" />
              <el-option label="V" value="5" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="左下肢近端肌力:">
            <el-select v-model="form.muscularStrength5" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="I" value="1" />
              <el-option label="II" value="2" />
              <el-option label="III" value="3" />
              <el-option label="IV" value="4" />
              <el-option label="V" value="5" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="左下肢远端肌力:">
            <el-select v-model="form.muscularStrength6" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="I" value="1" />
              <el-option label="II" value="2" />
              <el-option label="III" value="3" />
              <el-option label="IV" value="4" />
              <el-option label="V" value="5" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="右下肢近端肌力:">
            <el-select v-model="form.muscularStrength7" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="I" value="1" />
              <el-option label="II" value="2" />
              <el-option label="III" value="3" />
              <el-option label="IV" value="4" />
              <el-option label="V" value="5" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="右下肢远端肌力:">
            <el-select v-model="form.muscularStrength8" placeholder="请选择">
              <el-option label=" " value="0" />
              <el-option label="I" value="1" />
              <el-option label="II" value="2" />
              <el-option label="III" value="3" />
              <el-option label="IV" value="4" />
              <el-option label="V" value="5" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="眼肌型量表:">
            <el-radio-group v-model="form.eye" @change="handleRadio">
              <el-radio :label="0">是</el-radio>
              <el-radio :label="1">否</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <eye-movements v-show="eyeValue === 0" ref="eyeMovements" />
      <ocular-qmg v-show="eyeValue === 0" ref="ocularQmg" />
      <mgadl ref="mgadl" />
      <qmg ref="qmg" />
      <mg ref="mg" />
      <mgqol15 ref="mgqol15" />
      <omtype ref="omtype" />
      <el-form-item>
        <el-button type="primary" @click="onSubmit">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import Mgadl from '../jixian/mgadl.vue'
import Qmg from '../jixian/qmg.vue'
import Mg from '../jixian/mg.vue'
import Mgqol15 from '../jixian/mgqol15.vue'
import Omtype from '../jixian/omtype.vue'
import EyeMovements from '../jixian/eye-movements.vue'
import OcularQmg from '../jixian/ocular-qmg.vue'
import { addHealthCheckup } from '@/api/testDashboard'
import { initData } from '@/api/data'

export default {
  components: {
    Mgadl,
    Qmg,
    Mg,
    Mgqol15,
    Omtype,
    EyeMovements,
    OcularQmg
  },
  data() {
    return {
      form: {
        blepharoptosis: '0',
        eyeMovementDisorder: '0',
        diplopia: '0',
        sorenes: '0',
        mumps: '0',
        dysarthria: '0',
        drink: '0',
        neckFlexion: '0',
        toeWalking: '0',
        heelWalking: '0',
        squat: '0',
        muscularStrength1: '0',
        muscularStrength2: '0',
        muscularStrength3: '0',
        muscularStrength4: '0',
        muscularStrength5: '0',
        muscularStrength6: '0',
        muscularStrength7: '0',
        muscularStrength8: '0',
        eye: 0,
        pId: this.pId,
        id: ''
      },
      eyeValue: '',
      params: {
        healthCheckup: {},
        eyeMovementsScore: {},
        ocularQmgScore: {},
        mgAdlScore: {},
        qmgScore: {},
        mgScore: {},
        mgQolScore: {},
        id: '',
        pid: this.pId
      },
      query: {
        pid: this.pId
      }
    }
  },
  inject: [
    'pId'
  ],
  created() {
    initData('/api/patient/detail/queryBaseLineCase', this.query).then(res => {
      console.log(res)
      res.healthCheckup.blepharoptosis = res.healthCheckup.blepharoptosis + ''
      res.healthCheckup.eyeMovementDisorder = res.healthCheckup.eyeMovementDisorder + ''
      res.healthCheckup.diplopia = res.healthCheckup.diplopia + ''
      res.healthCheckup.sorenes = res.healthCheckup.sorenes + ''
      res.healthCheckup.mumps = res.healthCheckup.mumps + ''
      res.healthCheckup.dysarthria = res.healthCheckup.dysarthria + ''
      res.healthCheckup.drink = res.healthCheckup.drink + ''
      res.healthCheckup.neckFlexion = res.healthCheckup.neckFlexion + ''
      res.healthCheckup.toeWalking = res.healthCheckup.toeWalking + ''
      res.healthCheckup.heelWalking = res.healthCheckup.heelWalking + ''
      res.healthCheckup.squat = res.healthCheckup.squat + ''
      res.healthCheckup.muscularStrength1 = res.healthCheckup.muscularStrength1 + ''
      res.healthCheckup.muscularStrength2 = res.healthCheckup.muscularStrength2 + ''
      res.healthCheckup.muscularStrength3 = res.healthCheckup.muscularStrength3 + ''
      res.healthCheckup.muscularStrength4 = res.healthCheckup.muscularStrength4 + ''
      res.healthCheckup.muscularStrength5 = res.healthCheckup.muscularStrength5 + ''
      res.healthCheckup.muscularStrength6 = res.healthCheckup.muscularStrength6 + ''
      res.healthCheckup.muscularStrength7 = res.healthCheckup.muscularStrength7 + ''
      res.healthCheckup.muscularStrength8 = res.healthCheckup.muscularStrength8 + ''
      this.form = res.healthCheckup
      this.$refs.eyeMovements.form = res.eyeMovementsScore
      this.$refs.ocularQmg.form = res.ocularQmgScore
      this.$refs.mgadl.form = res.mgAdlScore
      this.$refs.qmg.form = res.qmgScore
      this.$refs.mg.form = res.mgScore
      this.$refs.mgqol15.form = res.mgQolScore
      this.$refs.omtype.form.osserman = res.healthCheckup.osserman
      this.$refs.omtype.form.mgfa = res.healthCheckup.mgfa
      this.eyeValue = res.healthCheckup.eye
    })
  },
  methods: {
    onSubmit() {
      this.params.healthCheckup = this.form
      this.params.healthCheckup.osserman = this.$refs.omtype.form.osserman
      this.params.healthCheckup.mgfa = this.$refs.omtype.form.mgfa
      this.params.eyeMovementsScore = this.$refs.eyeMovements.form
      this.params.ocularQmgScore = this.$refs.ocularQmg.form
      this.params.mgAdlScore = this.$refs.mgadl.form
      this.params.qmgScore = this.$refs.qmg.form
      this.params.mgScore = this.$refs.mg.form
      this.params.mgQolScore = this.$refs.mgqol15.form
      addHealthCheckup(this.params).then(res => {
        alert('success')
      })
    },
    handleRadio(v) {
      this.eyeValue = v
    }
  }
}
</script>

<style>

</style>
